﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace NOS.Configuration.Services
{
    [Serializable()]
    public struct DataObject
    {
        public string ServiceName { get; set; }
        public string Assembly { get; set; }
    }

    [Serializable]
    public class DataObjectCollection : List<DataObject>
    {
        #region . Contrutores .

        public DataObjectCollection(DataObject Item)
        {
            Add(Item);
        }

        public DataObjectCollection() : base() { }

        #endregion

        public void SaveToFile(string FileName)
        {
            XmlSerializer xmls = new XmlSerializer(typeof(DataObjectCollection));
            XmlTextWriter xmlw = new XmlTextWriter(FileName,Encoding.UTF8);
            xmls.Serialize(xmlw,this);
            xmlw.Close();
        }

        public static DataObjectCollection LoadFromFile(string FileName)
        {
            XmlSerializer xmls = new XmlSerializer(typeof(DataObjectCollection));
            XmlTextReader xmlw = new XmlTextReader(FileName);
            DataObjectCollection TmpReturn = (DataObjectCollection)xmls.Deserialize(xmlw, "");
            xmlw.Close();
            return TmpReturn;
        }
    }

}
